[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
ifstream File Input Stream
The ifstream class is used for file input in C++. The
important member functions in this class are:
istream &get(ch); Get one char from stream associated with object
char &ch; Location to put character at
istream &read(buf, num); Read num bytes from this object's stream
unsigned char *buf; Data buffer
int num; Number of bytes to read
void open(filename, mode, access); Open a file.
char *filename; The file's name
int mode; Open mode:
in = 0x01 Open for reading
out = 0x02 Open for writing
ate = 0x04 Seek to eof upon open
app = 0x08 Append mode
trunc = 0x10 Truncate file if already exists
nocreate = 0x20 Open fails if doesn't exist
noreplace = 0x40 Open fails if already exists
binary = 0x80 Binary (not text) file
int access; Access:
0 = Normal file
1 = Read-only file
2 = Hidden file
4 = System file
8 = Archive bit set
void close(); Close file associated with this object (no parameters).
int eof(); Return nonzero value when the end of the file is reached.
istream &seekg(offset, origin); Move data get pointer
streamoff offset; Type defined in IOSTREAM.H
seek_dir origin; Seek_dir is an enumeration; possible values:
ios::beg = Beginning
ios::cur = Current location
ios::end = End
See Also:
fstream
ofstream
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson